package refactor.replacetypecodewithstateorstrategy;

public class Employee {
    private EmployeeType employeeType;
    private int monthlySalary;
    private int commission;
    private int bonus;

    public Employee() {
    }

    public Employee(int type) {
        this.employeeType = EmployeeType.createEmployeeType(type);
    }

    public int calcPayAmount() {
        switch (getType()) {
            case EmployeeType.ENGINEER:
                return monthlySalary;
            case EmployeeType.SALESMAN:
                return monthlySalary + commission;
            case EmployeeType.MANAGER:
                return monthlySalary + bonus;
            default:
                throw new RuntimeException("Incorrect Employee");
        }
    }

    public int getType() {
        return employeeType.getType();
    }

    public void setType(int type) {
        this.employeeType = EmployeeType.createEmployeeType(type);
    }
}
